"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const cross_1 = require("../service/cross");
/**
 * Cross
 * @class
 */
class CrossController {
    /**
     * View process service information
     */
    info() {
        cross_1.crossService.info();
        return 'hello electron-egg';
    }
    /**
     * Get service url
     */
    getUrl(args) {
        return __awaiter(this, void 0, void 0, function* () {
            const { name } = args;
            const serverUrl = cross_1.crossService.getUrl(name);
            return serverUrl;
        });
    }
    /**
     * kill service
     * By default (modifiable), killing the process will exit the electron application.
     */
    killServer(args) {
        return __awaiter(this, void 0, void 0, function* () {
            const { type, name } = args;
            cross_1.crossService.killServer(type, name);
            return;
        });
    }
    /**
     * create service
     */
    createServer(args) {
        return __awaiter(this, void 0, void 0, function* () {
            const { program } = args;
            if (program == 'go') {
                cross_1.crossService.createGoServer();
            }
            else if (program == 'java') {
                cross_1.crossService.createJavaServer();
            }
            else if (program == 'python') {
                cross_1.crossService.createPythonServer();
            }
            return;
        });
    }
    /**
     * Access the api for the cross service
     */
    requestApi(args) {
        return __awaiter(this, void 0, void 0, function* () {
            const { name, urlPath, params } = args;
            const data = yield cross_1.crossService.requestApi(name, urlPath, params);
            return data;
        });
    }
}
CrossController.toString = () => '[class CrossController]';
exports.default = CrossController;
